package com.lisener;


import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionLisener implements HttpSessionListener{

	static int online=0;
	@Override
	public void sessionCreated(HttpSessionEvent s) {
		HttpSession session= s.getSession();
		System.out.println("session对象:"+session);
		Object uname=session.getAttribute("uname");
		System.out.println("uname:"+uname);	
		if(uname==null){
			online=online+1;
			session.setAttribute("online", online);
		}
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	

		
}
